﻿using B.S.BaseData.ErrorCode;
using B.S.BaseData.ErrorCode.ErrorCodes;
using B.S.DataBase.EFCoreServiers.Dtos.Meetings;
using B.S.DataBase.EFCoreServiers.IServices.Meetings;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.BaseData.ReadAPI.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    [ApiExplorerSettings(GroupName = "MeetingRoom")]
    public class MeetingRoomController : ControllerBase
    {
        private readonly IMeetingRoomServices _meetingRoomServices;
        private readonly ILogger<MeetingRoomController> _logger;

        public MeetingRoomController(
            IMeetingRoomServices meetingRoomServices,
            ILogger<MeetingRoomController> logger)
        {
            _meetingRoomServices = meetingRoomServices;
            _logger = logger;
        }
        /// <summary>
        /// 获取会议室列表
        /// </summary>
        /// <param name="getMeetingRoom">查询参数</param>
        /// <returns>会议室列表</returns>
        [HttpGet]
        public async Task<ApiResult<ApiPaging<GetMeetingRoomResponseDto>>> GetMeetingRoomList([FromQuery] GetMeetingRoomDto getMeetingRoom)
        {
            try
            {
                return await _meetingRoomServices.GetDepartmentListAsync(getMeetingRoom);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "获取会议室列表失败");
                return ApiResult<ApiPaging<GetMeetingRoomResponseDto>>.Fail(
                    "获取会议室列表失败：" + ex.Message,
                    StatusCodeEnum.Exception
                );
            }
        }






    }
}
